import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_custom_bottom_tab_bar/eachtab.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:panda/base/Constant.dart';
import 'package:panda/base/application.dart';
import 'package:panda/home/JIaodan.dart';
import 'package:panda/home/Shoudan.dart';

class ShopCarPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return ShopCarFragmentState();
  }
}

class ShopCarFragmentState extends State<ShopCarPage>
    with WidgetsBindingObserver, SingleTickerProviderStateMixin {
  TabController _tabController;
  final SlidableController slidableController = SlidableController();

  EasyRefreshController _controller = new EasyRefreshController();
  int currentStatus = 0;
  bool isSelectAll = false;
  var titles = ['交单', '收单'];
  bool isShow = true;
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    if (state == AppLifecycleState.resumed) {
      if (APPLIC.userInfoMap != null) {
      isShow = (APPLIC.userInfoMap['user_msg']['group_id'].toString() == "1"||APPLIC.userInfoMap['user_msg']['group_id'].toString() == "2");
      }
    }
  }

  @override
  void initState() {
    super.initState();
    _tabController =
        new TabController(vsync: this, initialIndex: 0, length: titles.length);
    WidgetsBinding.instance.addObserver(this);
    if (APPLIC.userInfoMap != null) {
      isShow = (APPLIC.userInfoMap['user_msg']['group_id'].toString() == "1"||APPLIC.userInfoMap['user_msg']['group_id'].toString() == "2");
    }
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    return  Scaffold(
      body: SafeArea(
        child:AnnotatedRegion<SystemUiOverlayStyle>(
        child: Column(
          children: <Widget>[
            Container(
              width: double.infinity,
              alignment: Alignment.center,
              
              color: white,
              child: new TabBar(
                isScrollable: true,
                controller: _tabController,
                indicatorColor: mainColor,
                labelColor: mainColor,
                labelPadding: EdgeInsets.all(0),
                unselectedLabelColor: Colors.black,
                tabs: <Widget>[
                  EachTab(
                    text: titles[0],
                    textStyle:
                        TextStyle(fontSize: ScreenUtil.getInstance().setSp(NORMAL_FONT_SIZE)),
                  ),
                  // Offstage(
                  //   offstage: true,
                  //   child: ,
                  // )
                  EachTab(
                      text: titles[1],
                      textStyle: TextStyle(
                          fontSize:
                              ScreenUtil.getInstance().setSp(NORMAL_FONT_SIZE)),
                    )
                ],
              ),
            ),
            Container(
              height: 1,
              width: double.infinity,
              color: f0Color,
            ),
            Expanded(
              child: TabBarView(
                controller: _tabController,
                physics: NeverScrollableScrollPhysics(), // 禁止滑动
                children: <Widget>[
                Center(child: new JiaoDanPage()),
                Center(child: ShouDanPage()),
                // Center(child: AllOrderPage(type: 9,)),
              ]),
            )
          ],
        ),
        value: SystemUiOverlayStyle.dark,
      ),
       )
    );
  }

  @override
  void dispose() {
    super.dispose();
    WidgetsBinding.instance.removeObserver(this); //销毁观察者
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return false;
  }
}
